var sdxFields = new SDX_Fields() ;

// TEXTBOX FIELD
sdxStringField = sdxFields.InsertField("String")
sdxStringField.DefaultValue=2
function sdxStringField_GetDisplayHTML(_Value)
{
 var html = _Value ;
 return html ;
}
sdxStringField.GetDisplayHTML = sdxStringField_GetDisplayHTML;
function sdxStringField_GetEditHTML(_Cell)
{
 var html = "<input class=\"spTxtboxs\" type='textbox' size=" + (document.getElementById(_Cell.HTMLID).offsetWidth/10) + " value='" + _Cell.Value + "' onchange=\"" + _Cell.GetEvalObjectString() + ".SetValue(this.value) \" />";
 return html ;
}
sdxStringField.GetEditHTML = sdxStringField_GetEditHTML;

// NUMBER TEXTBOX FIELD
sdxNumberField = sdxFields.InsertField("Number")
sdxNumberField.DefaultValue=0
function sdxNumberField_GetDisplayHTML(_Value)
{
 var html = _Value ;
 return html ;
}
sdxNumberField.GetDisplayHTML = sdxNumberField_GetDisplayHTML;
function sdxNumberField_GetEditHTML(_Cell)
{
 var html = "<input class=\"spTxtboxs\" type='textbox' size=" + (document.getElementById(_Cell.HTMLID).offsetWidth/10) + " onchange='if(isNaN(this.value) == false){ " + _Cell.GetEvalObjectString() + ".SetValue(this.value) }' value='" + _Cell.Value + "' />";
 return html ;
}
sdxNumberField.GetEditHTML = sdxNumberField_GetEditHTML;

// DATE TEXTBOX FIELD
sdxDateField = sdxFields.InsertField("Date")
sdxDateField.DefaultValue=0
function sdxDateField_CheckData(_NewValue, _Cell)
{
 dateArray = _NewValue.split("/") ;
 if(dateArray.length == 3)
 {
  if( isNaN(dateArray[0]) == false && isNaN(dateArray[1]) == false && isNaN(dateArray[2]) == false )
  {
   var day = new Number(dateArray[0]) ;
   var month = new Number(dateArray[1]) ;
   var year = new Number(dateArray[2]) ;
   var date = new Date(year,month,day) ;
   _Cell.SetValue(date) ;
  }
 }
}
function sdxDateField_GetDisplayHTML(_Value)
{
 if(_Value == "" || _Value == null)
    return "";
 var html = ('0' + _Value.getDate()).substr((_Value.getDate().toString().length>1?1:0) ,2) + '/' + ('0' + (_Value.getMonth())).substr(((_Value.getMonth()).toString().length>1?1:0),2) + '/' + _Value.getFullYear() ;
 return html ;
}
sdxDateField.GetDisplayHTML = sdxDateField_GetDisplayHTML;
function sdxDateField_GetEditHTML(_Cell)
{
 var dateString;
 if( _Cell.Value != null && _Cell.Value != "" && _Cell.Value != undefined)
 {
     dateString = (_Cell.Value.getDate()>9?_Cell.Value.getDate():"0" + _Cell.Value.getDate()) + 
                  "/" +
                  ((_Cell.Value.getMonth()+1)>9?(_Cell.Value.getMonth()):"0" + (_Cell.Value.getMonth())) +
                  "/" +
                  _Cell.Value.getFullYear()
 }
 else
 {
     dateString = "null" ;
 }
 var html = "<input class=\"spTxtboxs\" type='textbox' size=12 title='Input format must be dd/mm/yyyy' onchange='sdxDateField_CheckData(this.value," + _Cell.GetEvalObjectString() + ")' value='" + dateString + "' />";
 return html ;
}
sdxDateField.GetEditHTML = sdxDateField_GetEditHTML;

// MULTILINE TEXTBOX MODE
sdxMemoField = sdxFields.InsertField("Memo")
sdxMemoField.DefaultValue=2
function sdxMemoField_GetDisplayHTML(_Value)
{
 var html = _Value.toString().replace(/\n/gi,'<BR>');
 return html ;
}
sdxMemoField.GetDisplayHTML = sdxMemoField_GetDisplayHTML;
function sdxMemoField_GetEditHTML(_Cell)
{
 var html = "<Textarea onchange='" + _Cell.GetEvalObjectString() + ".SetValue(this.value)'>" + _Cell.Value; + " </Textarea>";
 return html ;
}
sdxMemoField.GetEditHTML = sdxMemoField_GetEditHTML;

// CHECKBOX MODE
sdxBooleanField = sdxFields.InsertField("Boolean")
sdxBooleanField.DefaultValue=1
function sdxBooleanField_GetDisplayHTML(_Value)
{
 var html = ( _Value=="1"?"true":"false" )
 return html ;
}
sdxBooleanField.GetDisplayHTML = sdxBooleanField_GetDisplayHTML;
function sdxBooleanField_GetEditHTML(_Cell)
{
 var html = "<input type='checkbox' onchange='" + _Cell.GetEvalObjectString() + ".SetValue(this.checked?1:0)' " + ( _Cell.Value=="1"?"checked":"" ) + ">";
 return html ;
}
sdxBooleanField.GetEditHTML = sdxBooleanField_GetEditHTML;

// SELECTBOX MODE
sdxSelectboxField = sdxFields.InsertField("Selectbox")
sdxSelectboxField.DefaultValue=2
function sdxSelectboxField_GetDisplayHTML(_Value)
{
 var text = "" ;
 for(var nX in this.DataSource)
 {
  if(this.DataSource[nX][0] == _Value)
  {
   text = this.DataSource[nX][1] ;
  }
 }
 var html = text ;
 return html ;
}
sdxSelectboxField.GetDisplayHTML = sdxSelectboxField_GetDisplayHTML;
function sdxSelectboxField_GetEditHTML(_Cell)
{
 var text = "<select class='Selectbox' onchange='" + _Cell.GetEvalObjectString() + ".SetValue(this.options[this.selectedIndex].value)'>" ;
 for(var nX in this.DataSource)
 {
   text += "<option value = " + this.DataSource[nX][0] + " " + (this.DataSource[nX][0] == _Cell.Value?"selected":"") + ">" + this.DataSource[nX][1] + "</option>" ;
 }
 text += "</select>"
 var html = text ;
 return html ;
}
sdxSelectboxField.GetEditHTML = sdxSelectboxField_GetEditHTML;

// SELECTBOX MODE
sdxRadioGroupField = sdxFields.InsertField("RadioGroup")
sdxRadioGroupField.DefaultValue=2
function sdxRadioGroupField_GetDisplayHTML(_Value)
{
 var text = "" ;
 for(var nX in this.DataSource)
 {
  if(this.DataSource[nX][0] == _Value)
  {
   text = this.DataSource[nX][1] ;
  }
 }
 var html = text ;
 return html ;
}
sdxRadioGroupField.GetDisplayHTML = sdxSelectboxField_GetDisplayHTML;
function sdxRadioGroupField_GetEditHTML(_Cell)
{
 var text = "" ;
 for(var nX in this.DataSource)
 {
   text += "<input type='radio' name='" + _Cell.Name + "' onclick='" + _Cell.GetEvalObjectString() + ".SetValue(this.value)' value = '" + this.DataSource[nX][0] + "' " + (this.DataSource[nX][0] == _Cell.Value?"checked":"") + "> " + this.DataSource[nX][1] ;
 }
 var html = text ;
 return html ;
}
sdxRadioGroupField.GetEditHTML = sdxRadioGroupField_GetEditHTML;
